<template>
	<view class="wrapper">
		<view class="add-coupon">
			<view class="add-coupon-li">
				<view class="add-coupon-li-l">
					优惠券价格：
				</view>
				<input type="text" v-model="couponData.reduce" placeholder="请输入优惠券价格，如:10" placeholder-style="color:#999999" />
				<view class="price-t">
					元
				</view>
			</view>
			<view class="add-coupon-li">
				<view class="add-coupon-li-l">
					优惠券使用条件：
				</view>
				<input type="text" v-model="couponData.satisfy" placeholder="请输入使用价格，如:100" placeholder-style="color:#999999" />
				<view class="price-t">
					元
				</view>
			</view>
			<view class="add-coupon-li">
				<view class="add-coupon-li-l">
					有效期：
				</view>
				<input type="text" v-model="couponData.day" placeholder="请输入天数，如:3" placeholder-style="color:#999999" />
				<view class="price-t">
					天
				</view>
			</view>
		</view>
		<view @click="addBtn" class="coupon-btn">
			添加
		</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	export default {
		data() {
			return {	
				couponData:{
					satisfy:'',//满足价钱
					reduce:'',//减少价钱
					day:'',//有效时长（天）
				}
			}
		},
		onLoad() {
			
		},
		methods: {
			addBtn(){
				this.api._post('/Coupon/couponAdd',this.couponData).then(res=>{
					if(res.status==1){
						this.$refs.uToast.show({
							title: res.message,
							type: 'success'
						})
						this.couponData= {
							satisfy:'',//满足价钱
							reduce:'',//减少价钱
							day:'',//有效时长（天）
						}
					}else{
						this.$refs.uToast.show({
							title: res.message,
							type: 'error',
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import url('../../common/common.css');
	.add-coupon{
		width: 100%;
		.add-coupon-li{
			width: 90%;
			margin: 0 auto;
			height: 120upx;
			display: flex;
			justify-content: flex-start;
			align-items: center;
			border-bottom: 1upx solid #EEEEEE;
			.add-coupon-li-l{
				width: 280upx;
				font-size:30upx;
				font-family:PingFangSC;
				font-weight:400;
				color:rgba(0,0,0,1);
			}
			>input{
				width:400upx;
				height:80upx;
				background:rgba(247,248,250,1);
				font-size:28upx;
				font-family:PingFangSC;
				font-weight:400;
				padding: 0 21upx;
			}
			.price-t{
				margin-left: 10upx;
				font-size:30upx;
				font-family:PingFangSC;
				font-weight:400;
				color:rgba(0,0,0,1);
			}
		}
	}
	.coupon-btn{
		margin: 150upx auto;
		width:400upx;
		height:80upx;
		text-align: center;
		line-height: 80upx;
		background:rgba(247,0,0,1);
		box-shadow:0px 2upx 24upx 0px rgba(251,88,88,1);
		border-radius:40upx;
		font-size:34upx;
		font-family:PingFangSC;
		font-weight:400;
		color:rgba(255,255,255,1);
	}
</style>
